package org.ns.myblogs.controller;

import org.ns.myblogs.pojo.ResponseMap;
import org.ns.myblogs.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/page/article")
public class ArticlePageController {

    @Autowired
    ArticleService articleService;

    @RequestMapping("/index")
    public ModelAndView value(@RequestParam(name = "pageNo", defaultValue = "1") int pageNo,
                              @RequestParam(name = "pageSize", defaultValue = "2") int pageSize) {
        // 获得应答数据 pageNo 页数， pageSize 每页数量
        ResponseMap responseMap = articleService.list(pageNo, pageSize);
        ModelAndView modelAndView = new ModelAndView("/client/index.html");
        modelAndView.addObject("data", responseMap);
        return modelAndView;
    }
}
